<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>系统设置</title>
    <link rel="stylesheet" href="__TPL__/frame/layui/css/layui.css">
    <link rel="stylesheet" href="__TPL__/frame/static/css/style.css">
    <link rel="icon" href="__TPL__/frame/static/image/code.png">
</head>
<body class="body">
<span style="font-size: 20px;color: #c2c2c2;margin-left: 20px">基本配置</span>
<hr>
<form class="layui-form" action="">

    <div class="layui-form-item">
        <label class="layui-form-label">秘钥</label>
        <div class="layui-input-inline">
            <input type="text" name="password" placeholder="请输入秘钥" lay-verify="required" autocomplete="off"
                   value="{$password}"
                   class="layui-input"><br>
            <span style="color: red">修改此项会重新变更所有用户密码为默认密码!</span>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">默认密码</label>
        <div class="layui-input-inline">
            <input type="text" name="default_pwd" placeholder="请输入默认密码" lay-verify="required" autocomplete="off"
                   value="{$default_pwd}"
                   class="layui-input"><br>
            <span style="color: red">添加新用户时的密码</span>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">严格权限</label>
            <div class="layui-input-block">
                {if condition="$district eq 'T'"}
                <input type="checkbox" name="district" title="开启" lay-skin="primary" checked>
                {else /}
                <input type="checkbox" name="district" title="开启" lay-skin="primary">
                {/if}<br>
                <span style="color: red">开启时将检测所有用户的可执行方法，无权限将不可使用，适用于对安全性要求较高的环境</span>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="add_submit">修改系统配置</button>
        </div>
    </div>
</form>
<span style="font-size: 20px;color: #c2c2c2;margin-left: 20px">系统操作</span>
<hr>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-danger" id="reset_action">重置所有方法</button>
            <br>
            <span style="color: red">系统内存在所有方法进行重置,会影响权限!</span>
        </div>
    </div>

<script src="__TPL__/frame/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'jquery'], function () {
        var form = layui.form
            , layer = layui.layer
            , $ = layui.jquery;
        form.on('submit(add_submit)', function (data) {
            $.ajax({
                url: '{:url("Auth/editConfigPost")}',
                type: 'post',
                data: data.field,
                dataType: 'json',
                success: function (data) {
                    if (data.code === 1) {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.location.reload();
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 2000})
                    }
                }
            });
            return false;
        });
        $('#reset_action').click(function () {
            layer.confirm('是否重置所有方法?', {icon: 3, title:'提示'}, function(index){
                $.ajax({
                    url:"{:url('Set/refreshAllFunctions')}",
                    dataType:'json',
                    success:function (data) {
                        if (data.code === 1){
                            parent.location.reload();
                        }else{
                            layer.msg(data.msg);
                        }
                    }
                });
                layer.close(index);
            });
        })
    });
</script>
</body>
</html>